import InteractiveBase from "../../../LevelCommon/InteractiveBase";
import LevelBaseControl from "../../../LevelCommon/LevelBaseControl";
import { utils } from "../../../../utils/CommonUtil";

export default class FluorescentObj extends InteractiveBase {
    /** 需要的道具id*/
    public needPropId: number;
    private curLevelControl: LevelBaseControl;
    private curMaterial:Laya.BlinnPhongMaterial;
    /** 是否要使用掉道具*/
    public isShouldUse: boolean = false;
    /** 当前是否已经显示了记号*/
    private isShow: boolean = false;
    /** 是否一开始就显示出来 */
    public isShowStart: boolean = false;

    private mowner :Laya.MeshSprite3D;

    private originalClor: Laya.Vector4;
    onStart() {
        this.curLevelControl = window.gameFacade.LevelMng.GetCurLevelControl();
        this.mowner = this.owner as Laya.MeshSprite3D;
        this.curMaterial = this.mowner.meshRenderer.material as Laya.BlinnPhongMaterial;
        this.mowner.active = true;
        this.curMaterial.albedoColorA = 0;
        this.originalClor = this.curMaterial.albedoColor.clone();
        if (this.isShowStart) {
            {
                this.curMaterial.albedoColorA = 1;
            }
        }
    }

    protected InteractiveLogic(): boolean {
        if (this.isShow) {
            return false;
        }
        /** 判断是否选择了需要的道具*/
        if (this.curLevelControl.IsSelectProp(this.needPropId)) {
            if (this.isShouldUse) {
                this.curLevelControl.UseCurProp();
            }
            /** 慢慢显示记号*/
            //curMaterial.DOFloat(1, "_BloodAmount", 2);
            utils.CommonUtils.DOColorTween(this.curMaterial,new Laya.Vector4( this.originalClor.x,this.originalClor.y,this.originalClor.z,1),2000,null);
            this.isShow = true;
            this.CallToLevel(this.owner.name + "_Blood_Amount");
        }
        return false;
    }
}